/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: Frank
 * 系统版本: 1.0.0
 * 开发人员: Frank
 * 开发时间: 2019/12/11 16:52
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.spring.arch.uaa.model;

import com.spring.arch.common.jpa.model.AbstractPersistableModel;
import com.spring.arch.common.jpa.model.AbstractPersistableModel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 * 人员角色信息
 *
 * @author Frank
 * @version 1.0.0.1
 * @since 2019/12/11 16:52
 */
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@Getter
@Setter
@Entity
@Table(name = "organization_employee_role")
public class OrganizationEmployeeRole extends AbstractPersistableModel {

    private static final long serialVersionUID = -7447098134953494644L;

    /**
     * 人员信息
     */
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    private OrganizationEmployee organizationEmployee;

    /**
     * 角色信息
     */
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    private Role role;

    /**
     * 租户，冗余
     */
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    private Tenant tenant;

    /**
     * 组织信息，冗余
     */
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    private Organization organization;

    /**
     * 所属项目，冗余
     */
    @ManyToOne(fetch = FetchType.LAZY)
    private Project project;

    public OrganizationEmployeeRole(@NotNull OrganizationEmployee organizationEmployee,
                                    @NotNull Role role,
                                    @NotNull Tenant tenant,
                                    @NotNull Organization organization,
                                    Project project) {
        this.organizationEmployee = organizationEmployee;
        this.role = role;
        this.tenant = tenant;
        this.organization = organization;
        this.project = project;
    }
}
